package com.xpgk.app.login;

import com.jfinal.core.Controller;
import com.xpgk.dto.AjaxRender;
import com.xpgk.mvc.base.BaseValidator;
import com.xpgk.mvc.bentryRegister.Customer;

import jodd.util.StringUtil;

public class AppLoginValidator extends BaseValidator{

	@Override
	protected void validate(Controller controller) {
		Customer customer = controller.getModel(Customer.class);
		String userName = customer.getStr(Customer.column_userName);
		String password = customer.getStr(Customer.column_password);
		if(StringUtil.isBlank(userName)){
			addError("msg", "请输入手机号");
			return;
		}
		if(StringUtil.isBlank(password)){
			addError("msg", "请输入密码");
			return;
		}
		controller.setAttr("customer", customer);
	}
	
	@Override
	protected void handleError(Controller controller) {
		controller.render(AjaxRender.error((String)controller.getAttr("msg")));
	}


}
